// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.worldMap.symbols;

import java.util.ArrayList;
import java.util.HashMap;
import zombie.core.textures.Texture;

public final class MapSymbolDefinitions {
    private static MapSymbolDefinitions instance;
    private final ArrayList<MapSymbolDefinitions.MapSymbolDefinition> m_symbolList = new ArrayList();
    private final HashMap<String, MapSymbolDefinitions.MapSymbolDefinition> m_symbolByID = new HashMap();

    public static MapSymbolDefinitions getInstance() {
        if (instance == null) {
            instance = new MapSymbolDefinitions();
        }

        return instance;
    }

    public void addTexture(String id, String path, int width, int height) {
        MapSymbolDefinitions.MapSymbolDefinition mapSymbolDefinition = new MapSymbolDefinitions.MapSymbolDefinition();
        mapSymbolDefinition.id = id;
        mapSymbolDefinition.texturePath = path;
        mapSymbolDefinition.width = width;
        mapSymbolDefinition.height = height;
        this.m_symbolList.add(mapSymbolDefinition);
        this.m_symbolByID.put(id, mapSymbolDefinition);
    }

    public void addTexture(String id, String path) {
        Texture texture = Texture.getSharedTexture(path);
        if (texture == null) {
            this.addTexture(id, path, 18, 18);
        } else {
            this.addTexture(id, path, texture.getWidth(), texture.getHeight());
        }
    }

    public int getSymbolCount() {
        return this.m_symbolList.size();
    }

    public MapSymbolDefinitions.MapSymbolDefinition getSymbolByIndex(int index) {
        return (MapSymbolDefinitions.MapSymbolDefinition)this.m_symbolList.get(index);
    }

    public MapSymbolDefinitions.MapSymbolDefinition getSymbolById(String id) {
        return (MapSymbolDefinitions.MapSymbolDefinition)this.m_symbolByID.get(id);
    }

    public static void Reset() {
        if (instance != null) {
            getInstance().m_symbolList.clear();
            getInstance().m_symbolByID.clear();
        }
    }

    public static final class MapSymbolDefinition {
        private String id;
        private String texturePath;
        private int width;
        private int height;

        public String getId() {
            return this.id;
        }

        public String getTexturePath() {
            return this.texturePath;
        }

        public int getWidth() {
            return this.width;
        }

        public int getHeight() {
            return this.height;
        }
    }
}
